package demo.io;

import java.io.IOException;
import java.net.Socket;

/**
 * @author Admin
 */
public class IOClient {
  public static void main(String[] args) {
    new Thread(new Runnable() {
      @Override
      public void run() {
        Socket socket = null;
        try {
          socket = new Socket("localhost", 8000);
        } catch (IOException e) {
          e.printStackTrace();
        }
        while (true) {
          try {
            socket.getOutputStream().write("hello world".getBytes());
            Thread.sleep(2000);
          } catch (IOException e) {
            e.printStackTrace();
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      }
    }).start();
  }
}
